import request from '@/utils/request'

const base = '/product/category'

export function getCategoryMenus() {
    return request.get(`${base}/list/tree`)
}

export function deleteMenus( catIds: number[] ) {
    const urlSearchParams = new URLSearchParams()
    catIds.forEach(item => urlSearchParams.append('catIds', item.toString()))
    return request.delete(`${base}?${urlSearchParams.toString()}`)
}

export function addCategory(data) {
    return request.post(`${base}`, data)
}

export function updateCategory(params) {
    return request.put(`${base}`, params)
}

export function getCategory(catId) {
    return request.get(`${base}/${catId}`)
}

export function updateListCategory(data) {
    return request.put(`${base}/update_list`, data)
}